local _, GrifonOvaleScripts = ...

GrifonOvaleScripts.script.MAGE.Attilio = {
	desc = "[5.4] Attilio: Mage frost",
	code =
[[
	
Define(alter_time 110909)
	SpellInfo(alter_time duration=6)
Define(alter_time_activate 108978)
	SpellInfo(alter_time_activate cd=180)
Define(arcane_barrage 44425)
	SpellInfo(arcane_barrage cd=3)
	SpellAddDebuff(arcane_barrage arcane_charge=0)
Define(arcane_blast 30451)
	SpellAddDebuff(arcane_blast arcane_charge=1)
Define(arcane_brilliance 1459)
	SpellInfo(arcane_brilliance duration=3600)
	SpellAddBuff(arcane_brilliance arcane_brilliance=1)
Define(arcane_charge 36032)
	SpellInfo(arcane_charge duration=10)
Define(arcane_explosion 1449)
	SpellAddDebuff(arcane_explosion arcane_charge=refresh)
Define(arcane_missiles 5143)
	SpellInfo(arcane_missiles duration=2)
	SpellAddDebuff(arcane_missiles arcane_charge=1)
Define(arcane_missiles_aura 79683)
	SpellInfo(arcane_missiles_aura duration=20)
Define(arcane_power 12042)
	SpellInfo(arcane_power cd=90 duration=15)
	SpellAddBuff(arcane_power arcane_power=1)
Define(blazing_speed 108843)
	SpellInfo(blazing_speed cd=25 duration=1)
Define(blazing_speed_talent 2)
Define(blink 1953)
	SpellInfo(blink cd=15)
Define(blizzard 10)
	SpellInfo(blizzard canStopChannelling=8 duration=8 haste=spell tick=1)
Define(brain_freeze_aura 57761)
	SpellInfo(brain_freeze_aura duration=15)
Define(cold_snap 11958)
	SpellInfo(cold_snap cd=180)
Define(cold_snap_talent 12)
Define(combustion 11129)
	SpellInfo(combustion cd=45)
	SpellInfo(combustion cd=90 glyph=glyph_of_combustion)
	SpellInfo(combustion cd=36 itemset=T14 itemcount=4)
	SpellInfo(combustion cd=72 glyph=glyph_of_combustion itemset=T14 itemcount=4)
	SpellAddTargetDebuff(combustion combustion_aura=1)
Define(combustion_aura 83853)
	SpellInfo(combustion_aura duration=10 haste=spell tick=1)
	SpellInfo(combustion_aura addduration=10 glyph=glyph_of_combustion)
Define(conjure_brilliant_mana_gem 119316)
Define(conjure_mana_gem 759)
Define(counterspell 2139)
	SpellInfo(counterspell cd=24 duration=6)
Define(deep_freeze 44572)
	SpellInfo(deep_freeze cd=30 duration=5)
	SpellAddBuff(deep_freeze fingers_of_frost_aura=-1)
	SpellAddTargetDebuff(deep_freeze deep_freeze=1)
Define(evocation 12051)
	SpellInfo(evocation cd=120 canStopChannelling=3 duration=6 tick=2)
	SpellInfo(evocation cd=0 duration=3 tick=1 talent=invocation_talent)
	SpellAddBuff(evocation arcane_charge=0 evocation=1)
Define(fingers_of_frost_aura 44544)
	SpellInfo(fingers_of_frost_aura duration=15)
Define(fire_blast 2136)
	SpellInfo(fire_blast cd=8)
Define(fireball 133)
	SpellInfo(fireball base=1561 bonussp=1.5)
Define(flamestrike 2120)
	SpellInfo(flamestrike cd=12 duration=8 haste=spell tick=2)
Define(frost_armor 7302)
Define(frost_bomb 112948)
	SpellInfo(frost_bomb cd=10 cd_haste=spell duration=4 haste=spell tick=4)
	SpellAddTargetDebuff(frost_bomb frost_bomb=1)
Define(frost_bomb_talent 15)
Define(frost_nova 122)
	SpellInfo(frost_nova cd=25 duration=8)
	SpellInfo(frost_nova addcd=-5 glyph=glyph_of_frost_nova)
Define(frostbolt 116)
	SpellInfo(frostbolt duration=15)
	SpellAddTargetDebuff(frostbolt frostbolt=1)
Define(frostfire_bolt 44614)
	SpellInfo(frostfire_bolt duration=8)
	SpellAddBuff(frostfire_bolt brain_freeze_aura=0)
	SpellAddTargetDebuff(frostfire_bolt frostfire_bolt=1)
Define(frostjaw 102051)
	SpellInfo(frostjaw cd=20 duration=8)
	SpellAddTargetDebuff(frostjaw frostjaw=1)
Define(frostjaw_talent 9)
Define(frozen_orb 84714)
	SpellInfo(frozen_orb cd=60 duration=10)
Define(glyph_of_combustion 56368)
Define(glyph_of_frost_nova 56376)
Define(glyph_of_icy_veins 56364)
Define(heating_up 48107)
	SpellInfo(heating_up duration=10)
Define(ice_barrier 11426)
	SpellInfo(ice_barrier cd=25 duration=60)
	SpellAddBuff(ice_barrier ice_barrier=1)
Define(ice_block 45438)
	SpellInfo(ice_block cd=300 duration=10)
	SpellAddBuff(ice_block ice_block=10)
Define(ice_floes 108839)
	SpellInfo(ice_floes cd=20 duration=15)
	SpellAddBuff(ice_floes ice_floes=1)
Define(ice_floes_talent 3)
Define(ice_lance 30455)
	SpellAddBuff(ice_lance fingers_of_frost_aura=-1)
Define(ice_ward 111264)
	SpellInfo(ice_ward cd=20 duration=30)
Define(ice_ward_talent 8)
Define(icy_veins 12472)
	SpellInfo(icy_veins cd=180 duration=20)
	SpellInfo(icy_veins addcd=-90 itemset=T14 itemcount=4)
	SpellAddBuff(icy_veins icy_veins=1)
Define(icy_veins_glyphed 131078)
	SpellInfo(icy_veins_glyphed cd=180 duration=20)
	SpellInfo(icy_veins_glyphed addcd=-90 itemset=T14 itemcount=4)
	SpellAddBuff(icy_veins_glyphed icy_veins_glyphed=1)
SpellList(icy_veins_aura 12472 131078)
Define(ignite 12654)
	SpellInfo(ignite duration=4 tick=2)
Define(incanters_absorption 116267)
	SpellInfo(incanters_absorption duration=25)
Define(incanters_ward 1463)
	SpellInfo(incanters_ward cd=25 duration=8)
	SpellAddBuff(incanters_ward incanters_ward=1)
Define(incanters_ward_talent 18)
Define(inferno_blast 108853)
	SpellInfo(inferno_blast cd=8)
	SpellInfo(inferno_blast base=624.5 bonussp=0.6)
Define(invocation_talent 16)
Define(invokers_energy 116257)
	SpellInfo(invokers_energy duration=60)
Define(living_bomb 44457)
	SpellInfo(living_bomb cd=1 duration=12 haste=spell tick=3)
	SpellAddTargetDebuff(living_bomb living_bomb=1)
Define(living_bomb_talent 14)
Define(mage_armor 6117)
Define(mirror_image 55342)
	SpellInfo(mirror_image cd=180)
Define(molten_armor 30482)
Define(nether_tempest 114923)
	SpellInfo(nether_tempest duration=12 haste=spell tick=1)
	SpellAddTargetDebuff(nether_tempest nether_tempest=1)
Define(nether_tempest_talent 13)
Define(presence_of_mind 12043)
	SpellInfo(presence_of_mind cd=90)
Define(presence_of_mind_talent 1)
Define(pyroblast 11366)
	SpellInfo(pyroblast duration=18 haste=spell tick=3)
	SpellInfo(pyroblast base=2061 bonussp=1.98)
	SpellAddTargetDebuff(pyroblast pyroblast=1)
Define(pyroblast_aura 48108)
	SpellInfo(pyroblast_aura duration=15)
Define(rune_of_power 116011)
Define(rune_of_power_aura 116014)
Define(rune_of_power_talent 17)
Define(scorch 2948)
Define(spellsteal 30449)
Define(temporal_displacement 80354)
	SpellInfo(temporal_displacement duration=600)
Define(time_warp 80353)
	SpellInfo(time_warp cd=300 duration=40)
	SpellAddBuff(time_warp time_warp=1)
	SpellAddDebuff(time_warp temporal_displacement=1)
Define(water_elemental 31687)
	SpellInfo(water_elemental cd=60)
Define(water_elemental_freeze 33395)
	SpellInfo(water_elemental_freeze cd=25 duration=8)
	SpellAddTargetDebuff(water_elemental_freeze water_elemental_freeze=1)

# Items
Define(brilliant_mana_gem 81901)
Define(jade_serpent_potion 76093)
Define(jade_serpent_potion_buff 105702)
	SpellInfo(jade_serpent_potion_buff duration=25)
Define(mana_gem 36799)

# Racials
Define(berserking 26297)
	SpellInfo(berserking cd=180 duration=10)
	SpellAddBuff(berserking berserking=1)
Define(blood_fury 20572)
	SpellInfo(blood_fury cd=120 duration=15)
	SpellAddBuff(blood_fury blood_fury=1)
Define(quaking_palm 107079)
	SpellInfo(quaking_palm cd=120 duration=4)
	SpellAddTargetDebuff(quaking_palm quaking_palm=1)
Define(stoneform 20594)
	SpellInfo(stoneform cd=120 duration=8)
	SpellAddBuff(stoneform stoneform=1)
Define(gift_of_the_naaru 28880)
        SpellInfo(gift_of_the_naaru cd=180 duration=15)

AddFunction UseRacialActions
{
	Spell(berserking)
	Spell(blood_fury)
}

AddFunction UseRacialInterruptActions
{
	if not target.Classification(worldboss) and target.InRange(quaking_palm) Spell(quaking_palm)
}

AddFunction UseRacialSurvivalActions
{
	#Spell(stoneform)
        Spell(gift_of_the_naaru)
}


AddFunction UseItemActions
{
	Item(HandsSlot usable=1)
}

AddCheckBox(AutoInterrupt "AutoInterrupt" default)
AddCheckBox(AutoIceBarrier "AutoIceBarrier" default)
AddCheckBox(AutoAlterTime "AutoAlterTime" default)
AddCheckBox(AutoSOS "AutoSOS" default)
AddCheckBox(AutoPotions "AutoPotions")
AddCheckBox(AutoDeepFreeze "AutoDeepFreeze" default)
AddCheckBox(AutoDeepFreeze "AutoDeepFreezeOnlyForInterrupt" default)
AddCheckBox(AOE "AOE" default)
AddCheckBox(NoDotPlayer "NoDotPlayer" default)

AddFunction Interrupt
{
	if {target.IsFriend(no) or {target.IsFriend() and target.IsCharmed()} } and target.IsInterruptible()
	{
		Spell(counterspell)
		if not target.Classification(worldboss) Spell(deep_freeze usable=1)
		UseRacialInterruptActions()
	}
}

AddFunction ConjureManaGem
{
	if Glyph(glyph_of_mana_gem) and ItemCharges(brilliant_mana_gem) <10 Spell(conjure_brilliant_mana_gem)
	if Glyph(glyph_of_mana_gem no) and ItemCharges(mana_gem) <3 Spell(conjure_mana_gem)
}

AddFunction UseManaGem
{
	if Glyph(glyph_of_mana_gem) Item(brilliant_mana_gem)
	if Glyph(glyph_of_mana_gem no) Item(mana_gem)
}

AddFunction UsePotion
{
	if CheckBoxOn(AutoPotions) and BuffPresent(burst_haste any=1) and target.Classification(worldboss) Item(jade_serpent_potion usable=1)
}

AddFunction MageBomb
{
	if TalentPoints(nether_tempest_talent)
	{
		if {target.DebuffExpires(nether_tempest) or target.TicksRemain(nether_tempest) <2} and target.TimeToDie() >6 Spell(nether_tempest)
	}
	if TalentPoints(living_bomb_talent)
	{
		if {target.DebuffExpires(living_bomb) or target.TicksRemain(living_bomb) <2} and target.TimeToDie() >{target.TickTime(living_bomb) * 3} Spell(living_bomb)
	}
	if TalentPoints(frost_bomb_talent)
	{
		if target.TimeToDie() > CastTime(frost_bomb) + target.TickTime(frost_bomb) Spell(frost_bomb)
	}
}

AddIcon specialization=3 help=main
{
	if not InCombat() 
	{
		ConjureManaGem()
	}

	if CheckBoxOn(AutoSOS)
	{
                #if HealthPercent() < 50 UseRacialSurvivalActions()
		if TalentPoints(cold_snap_talent) and HealthPercent() < 30 Spell(cold_snap)
		if HealthPercent() < 20 Spell(ice_block)
	}
        if CheckBoxOn(AutoIceBarrier) and BuffExpires(ice_barrier) Spell(ice_barrier)
        if CheckBoxOn(AutoInterrupt) Interrupt()

        if Spell(alter_time_activate) and BuffExpires(alter_time) UsePotion()
        if Spell(alter_time_activate) and BuffExpires(alter_time) UseItemActions()
        #spam ice lance on frozen target
        if target.DebuffPresent(44572) or target.DebuffPresent(122) or target.DebuffPresent(33395)
	{
		Spell(ice_lance)
	}
        if InCombat() and CheckBoxOn(AutoDeepFreeze) and not CheckBoxOn(AutoDeepFreezeOnlyForInterrupt) and not target.Classification(worldboss) Spell(deep_freeze usable=1)
        if InCombat() and Speed(more 0) and not BuffPresent(ice_floes)
	{
		Spell(ice_lance)
	}
	if PetPresent(no) Spell(water_elemental)
	if BuffExpires(spell_power_multiplier 400 any=1) or BuffExpires(critical_strike 400 any=1) Spell(arcane_brilliance)
	if BuffExpires(frost_armor) Spell(frost_armor)
        if CheckBoxOn(AutoAlterTime) and BuffPresent(brain_freeze_aura) and BuffPresent(fingers_of_frost_aura) and BuffExpires(alter_time) and BuffPresent(invokers_energy) Spell(alter_time_activate)
        if {InCombat() or target.DeadIn() > 10 } and {BuffExpires(invokers_energy) or ManaPercent() < 5 } and BuffExpires(alter_time) Spell(evocation)
        if BuffPresent(invokers_energy)
	{
		if not CheckBoxOn(NoDotPlayer) or not target.IsPlayer() MageBomb()
		if BuffPresent(brain_freeze_aura) Spell(frostfire_bolt)
		if BuffPresent(fingers_of_frost_aura) Spell(ice_lance)
        	if target.DeadIn() > 10 Spell(mirror_image)	
		if CheckBoxOn(AOE)  Spell(frozen_orb)
                if target.DeadIn() > 20 
		{
			if Glyph(glyph_of_icy_veins) Spell(icy_veins_glyphed)
			if Glyph(glyph_of_icy_veins no) Spell(icy_veins)
		}	
		Spell(frostbolt)
	}
}




]],
}
